class Solution {
public:
    int equalSubstring(string s, string t, int maxCost) {
        int ans=0,cost=0;
        for(int left=0,right=0;right<s.size();++right)
        {
            cost+=abs(s[right]-t[right]);
            while(left<=right&&cost>maxCost)
                cost-=abs(s[left]-t[left++]);
            ans=max(ans,right-left+1);
        }
        return ans;
    }
};
